/*
*	var error = require("../public/js/error");
*   error({"type":"empty","message":""});
*
*/
var extend = require("../../plugin/util/extend");
var errorRender = require("../ejs/error.ejs");


module.exports = function(options) {
	var setting,tempdata,bodyson;
    bodyson = [].slice.call(document.body.children);
    setting = {
    	"type":"empty",
    	"message":"优惠券没有了，去看看更多商品吧~",
    	"icon":"empty-shelf",
    	"showLink" :!0
    };
    if(typeof(options)=="undefined"){
    	options=setting;
    }
    if(typeof(options)=="string"){
    	switch(options){
    		case 'error':
		    setting = {
		    	"type":"error",
		    	"message":"页面出错啦，先看看更多商品吧~",
		    	"icon":"error",
		    	"showLink" :!1
		    };
    	}
    }
    tempdata =  extend(setting,options);
    bodyson.forEach(function(item){
        if(item.tagName.toUpperCase()!="SCRIPT"){
            item.parentElement.removeChild(item);
        }
    });
    document.body.insertAdjacentHTML('AfterBegin', errorRender(tempdata));
}

